package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 攻略分类
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@JsonIgnoreProperties("handler")
public class StrategyCatalog extends BaseDomain{
    public static final Boolean STATE_NORMAL=true;//启用
    public static final Boolean STATE_DISABLE=false;//禁用

    private String name;

    private Integer sequence;

    private Boolean state =STATE_NORMAL;

    private Strategy strategy;

    //设置关系--多对一的关系
    private List<StrategyDetail> details = new ArrayList<>();

    public String getStateDisplay(){
        if(state!=null){
            return state==true?"启用":"禁用";
        }
        return "";
    }

    public String getJson(){
        Map<String,Object> map =new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if(strategy!=null){
            map.put("strategyId",strategy.getId());
        }
        return JSONUtils.toJSONString(map);
    }


}